//
//  NetGetPostsWithCache.m
//  KidReading
//
//  Created by Yinjialiang on 16/3/28.
//  Copyright © 2016年 刘赞黄Telen. All rights reserved.
//

#import "NetGetPostsWithCache.h"
#import "ConstDefine.h"

@implementation NetGetPostsWithCache

static NetGetPostsWithCache* singlePostsWithCache = nil;
//创建单例
+ (instancetype)shareInstance
{
    if (singlePostsWithCache == nil) {
        @synchronized(self){
            singlePostsWithCache = [[NetGetPostsWithCache alloc] init];
        }
    }
    return singlePostsWithCache;
}


- (NSString *)getPushInfo {
    NSString *pushInfo = [[CacheData shareSingle].getUserLoginInfo loadPush_deviceToken];
    NSArray *pushArr = [pushInfo componentsSeparatedByString:@" "];
    NSString *deviceInfo = nil;
    NSString *baiduInfo = nil;
    deviceInfo = pushArr[0];
    if (pushArr.count >= 2) {
        baiduInfo = pushArr[1];
        for (NSInteger i = 0;i < pushArr.count;i ++) {
            NSString *tempItem = pushArr[i];
            if (tempItem.length > deviceInfo.length) {
                deviceInfo = tempItem;
            }
            if (tempItem.length < baiduInfo.length) {
                baiduInfo = tempItem;
            }
        }
    }
    
    NSMutableArray *dicArr = [NSMutableArray array];
    if (deviceInfo && deviceInfo.length > 0) {
        NSDictionary * devieDict = @{@"receiverId":deviceInfo,
                                     @"pushPlatform":@"ios"};
        [dicArr addObject:devieDict];
    }
    
    if (baiduInfo && baiduInfo.length > 0) {
        NSDictionary * baiDict = @{@"receiverId":baiduInfo,
                                     @"pushPlatform":@"baidu"};
        [dicArr addObject:baiDict];
    }
    
    NSString *finalPushInfo = nil;
    if (dicArr.count > 0) {
        finalPushInfo = [dicArr JRMJ_JSONString];
    }
    
    return finalPushInfo;
}

//登陆
- (void)loginJRSuccess:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    
    NSString* udid = [self getUMSuiid];
    NSInteger role = [CacheData shareSingle].getUserLoginInfo.role;
    NSDictionary* dict = @{@"uuid":udid,
                           @"role":@(role)};
    NSString * pushInfo = [self getPushInfo];
    if (pushInfo && pushInfo.length > 0) {
        dict = @{@"uuid":udid,
                 @"role":@(role),
                 @"pushInfo":pushInfo};
    }
    
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_login andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);

    } failure:^(NSError *error) {
        if (failure)failure(error);

    }];
}

//获取用户权限
- (void)getAuthorInfoFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    NSMutableDictionary *dict = [NSMutableDictionary new];
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    if (userInfo.role)[dict setObject:@(userInfo.role) forKey:@"role"];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getAuthorInfo baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getAuthorInfo,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
        
        if (success &&retDict)success(retDict,hasCache);

    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);

    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);

    }];
    
}
//获取首页信息
-(void)getHomePageFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict, BOOL onlyCache))cacheBack{
    if ([[NetRequestLimiter defaultLimiter] isOneLifeCycleLimitedWithLimitedPage:OneCycleLimitedPage_HomePage]) {
        [self getHomePageCache:^(NSDictionary *cacheRetDict) {
            if (cacheBack) {
                cacheBack(cacheRetDict, YES);
            }
        }];
    }else{
        NSMutableDictionary *dict = [NSMutableDictionary new];
        UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
        if (userInfo.role)[dict setObject:@(userInfo.role) forKey:@"role"];
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getHomePage baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getHomePage,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
            [[NetRequestLimiter defaultLimiter] updateOneLifeCycleLimitedWithLimitedPage:OneCycleLimitedPage_HomePage];
            if (success)success(retDict,hasCache);
            
        } failure:^(NSError *error,BOOL hasCache) {
            if (failure)failure(error,hasCache);
            
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict, NO);
            
        }];
    }
}
//获取首页缓存
-(void)getHomePageCache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCahce shareSingle] getCacheWithPort:__port_server_getHomePage BaseUrl:__Ser3_0_URL_Base_ KeyId:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getHomePage,@(userInfo.uid),userInfo.country_code] CacheBack:^(NSDictionary *retDict) {
        if (cacheBack) {
            cacheBack(retDict[@"retinfo"]);
        }
    }];
}

//获取书库信息
-(void)getLibraryFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    if ([[NetRequestLimiter defaultLimiter] isOneLifeCycleLimitedWithLimitedPage:OneCycleLimitedPage_Library]) {
        [self getLibraryCache:^(NSDictionary *cacheRetDict) {
            if (cacheBack) {
                cacheBack(cacheRetDict);
            }
        }];
    }else{
        NSMutableDictionary *dict = [NSMutableDictionary new];
        UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
        [dict setObject:@(15) forKey:@"menuId"];
        if (userInfo.role)[dict setObject:@(userInfo.role) forKey:@"role"];
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getLibrary baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getLibrary,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
            [[NetRequestLimiter defaultLimiter] updateOneLifeCycleLimitedWithLimitedPage:OneCycleLimitedPage_Library];
            if (success)success(retDict,hasCache);
            
        } failure:^(NSError *error,BOOL hasCache) {
            if (failure)failure(error,hasCache);
            
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
            
        }];
    }
}
//获取书库缓存
-(void)getLibraryCache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCahce shareSingle] getCacheWithPort:__port_server_getLibrary BaseUrl:__Ser3_0_URL_Base_ KeyId:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getLibrary,@(userInfo.uid),userInfo.country_code] CacheBack:^(NSDictionary *retDict) {
        if (cacheBack) {
            cacheBack(retDict[@"retinfo"]);
        }
    }];
}

//获取特殊书库缓存
-(void)getSpecialLibraryCache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCahce shareSingle] getCacheWithPort:__port_server_getSpecialLibrary BaseUrl:__Ser3_0_URL_Base_ KeyId:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getSpecialLibrary,@(userInfo.uid),userInfo.country_code] CacheBack:^(NSDictionary *retDict) {
        if (cacheBack) {
            cacheBack(retDict[@"retinfo"]);
        }
    }];
}

//获取特殊书库信息
-(void)getSpecialLibraryFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    //
    if ([[NetRequestLimiter defaultLimiter] isOneLifeCycleLimitedWithLimitedPage:OneCycleLimitedPage_SpecialLibrary]) {
        [self getSpecialLibraryCache:^(NSDictionary *cacheRetDict) {
            if (cacheBack) {
                cacheBack(cacheRetDict);
            }
        }];
    }else{
        NSMutableDictionary *dict = [NSMutableDictionary new];
        UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
        if (userInfo.role)[dict setObject:@(userInfo.role) forKey:@"role"];
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getSpecialLibrary baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getSpecialLibrary,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
            [[NetRequestLimiter defaultLimiter] updateOneLifeCycleLimitedWithLimitedPage:OneCycleLimitedPage_SpecialLibrary];
            if (success)success(retDict,hasCache);
            
        } failure:^(NSError *error,BOOL hasCache) {
            if (failure)failure(error,hasCache);
            
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
            
        }];
    }
}

//获取更多图书
-(void)getMoreBooksFromNetWithCollType:(NSString*)collType CollValue:(NSString *)collValue BookLang:(NSString*)bookLang PageIndex:(NSInteger)pageIndex OrderBy:(NSString*)orderBy Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    if (!bookLang) {
        bookLang = @"";
    }
    NSDictionary* params = @{@"pageIndex":@(pageIndex),@"orderBy":orderBy,@"collType":collType,@"collValue":collValue,@"bookLang":bookLang};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getMore baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@_%@_%@_%@",__keyId_port_getMore,@(userInfo.uid),userInfo.country_code,collType,collValue,@(pageIndex),orderBy] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取广告位对应图书合集
-(void)getAdBooksFromNetWithAdtype:(NSInteger)adType AdID:(NSInteger)adId PageIndex:(NSInteger)pageIndex OrderBy:(NSString*)orderBy Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{};
   // if (adType == ADType_AD) {
        params = @{@"itemId":@(adId),@"mediaType":@"ad",@"pageIndex":@(pageIndex),@"orderBy":orderBy};
   // }else if (adType == ADType_Banner){
        params = @{@"itemId":@(adId),@"mediaType":@"banner",@"pageIndex":@(pageIndex),@"orderBy":orderBy};
   // }
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getAdMore baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@_%@_%@_%@",__keyId_port_getAdMore,@(userInfo.uid),userInfo.country_code,@(adType),@(adId),@(pageIndex),orderBy] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取主题
-(void)getCateListFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestLimitedWithCacheType:RequestType_Post Port:__port_server_getCateList baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getCateList,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取等级
-(void)getLevelListFromNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getLevelList baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getLevelList,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取年级
-(void)getGradeListFromNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getGradeList baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getGradeList,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取年龄
- (void)getAgeListFromNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getAgeList baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getAgeList,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

-(void)getGradeCNListFromNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getGradeCN baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getGradeCN,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取英文图书列表
-(void)getENBookListFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestLimitedWithCacheType:RequestType_Post Port:__port_server_getEnglishBook baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getEnglishBook,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取中文图书列表
-(void)getZHBookListFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestLimitedWithCacheType:RequestType_Post Port:__port_server_getChineseBook baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getChineseBook,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
    
}

//获取中英文图书(more类型/带分页)
-(void)getZHOrEnBookListFromNetWithBookLang:(NSString*)bookLang OrderBy:(NSString*)orderBy PageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex),@"bookLang":bookLang,@"orderBy":orderBy};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getEnglishOrChineseBook baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@_%@_%@",__keyId_port_getEnglishOrChineseBook,@(userInfo.uid),userInfo.country_code,bookLang,orderBy,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取系列列表
-(void)getSeriesBookListFromNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getSeriesBookList baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getSeriesBookList,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//合并我的书架中的图书
-(void)mergeMineWithData_timestamp:(long long)data_timestamp MergeType:(NSInteger)mergeType UpdateArray:(NSArray*)updateArray DeleteArray:(NSArray*)deleteArray Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
//    //
//    if (!updateArray) updateArray = @[];
//    if (!deleteArray) deleteArray = @[];
//    NSDictionary* mDict = @{@"update":updateArray,@"delete":deleteArray};
//    NSData* Data = [NSJSONSerialization dataWithJSONObject:mDict options:NSJSONWritingPrettyPrinted error:nil];
//    NSString* jsondate = @"";
//    if (Data) {
//        jsondate = [[NSString alloc] initWithBytes:Data.bytes length:Data.length encoding:NSUTF8StringEncoding];
//    }
//    NSDictionary *dict = @{@"mineJson":jsondate,@"data_timestamp":@(data_timestamp)};
//    NSString* port = __port_server_mergeMine;
//    //if (mergeType == MergeType_Favor) {
//        dict = @{@"favorJson":jsondate,@"data_timestamp":@(data_timestamp)};
//        port = __port_server_mergeFavor;
//   // }
//   // if (mergeType == MergeType_Audio) {
//        dict = @{@"playJson":jsondate,@"data_timestamp":@(data_timestamp)};
//        port = __port_server_mergeAudio;
//   // }
//    //如果正在请求不发送重复请求
//    [[NetRequestWithCahce shareSingle] isRequestRuningWithPort:port baseUrl:__Ser3_0_URL_Base_ Completed:^(BOOL isRequesting) {
//        if (!isRequesting) {
//            //
//            [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:port andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
//                if (success) success(retDict);
//            } failure:^(NSError *error) {
//                if (failure) failure(error);
//            }];
//        }
//    }];
}

//获取收藏的图书
-(void)getFavorListFromNetWithTargetUserId:(NSInteger)targetUid success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary *dict = @{};
    NSString *keyStr = [NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getFavorList,@(userInfo.uid),userInfo.country_code];
    if (targetUid) {
        dict = @{@"targetUserId" : @(targetUid)};
        keyStr = [NSString stringWithFormat:@"%@_%@",__keyId_port_getFavorList,@(targetUid).description];
    }
    
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getFavorList baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:keyStr success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
    
}

//获取是否有推荐
-(void)getHasRecommendFromNetSuccess:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{

    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getHasRecommend andBaseUrl:__Ser3_0_URL_Base_ parameters:@{} success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
    
}

//获取推荐的图书
-(void)getRecommendListFromNetWithTargetUid:(NSInteger)targetUid role:(RecommendRoleType)roleType PageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    NSDictionary *dict = @{};
    NSString *tsSub = [NSDate timeString_zone_cur_utc];
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSString *keyStr = [NSString stringWithFormat:@"%@_%@_%@_%@_%@",__keyId_port_getRecommendList,@(userInfo.uid),userInfo.country_code,@(roleType),@(pageIndex)];
    if (roleType == RecommendRoleType_par) {
        dict = @{@"role":@(RecommendRoleType_par),@"timeArea":tsSub,@"pageIndex":@(pageIndex)};
        if (targetUid) {
            dict = @{@"role":@(RecommendRoleType_par),@"timeArea":tsSub,@"pageIndex":@(pageIndex),@"targetUserId":@(targetUid)};
            keyStr = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getRecommendList,@(targetUid),@(roleType),@(pageIndex)];
        }
    }else if(roleType == RecommendRoleType_tea){
        dict = @{@"role":@(RecommendRoleType_tea),@"timeArea":tsSub,@"pageIndex":@(pageIndex)};
        if (targetUid) {
            dict = @{@"role":@(RecommendRoleType_tea),@"timeArea":tsSub,@"pageIndex":@(pageIndex),@"targetUserId":@(targetUid)};
            keyStr = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getRecommendList,@(targetUid),@(roleType),@(pageIndex)];
        }
    }
    
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getRecommendList baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:keyStr NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//支付回调
-(void)getPayBackWithParams:(NSDictionary *)params FromNetSuccess:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getAppStoreCallBack andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取配置信息
-(void)getConfigFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestLimitedWithCacheType:RequestType_Post Port:__port_server_getConfig baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getConfig,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
    
}
//获取配置信息缓存
-(void)getConfigCacheSuccess:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCahce shareSingle] getCacheWithPort:__port_server_getConfig BaseUrl:__Ser3_0_URL_Base_ KeyId:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getConfig,@(userInfo.uid),userInfo.country_code] CacheBack:^(NSDictionary *retDict) {
        if (cacheBack) {
            cacheBack(retDict[@"retinfo"]);
        }
    }];
}

//修改用户收藏
-(void)favorUpdateWithType:(BOOL)addOrDel BookId:(NSInteger)bookId Success:(void (^)(BOOL add_noDel, BOOL IsSuccess))success failure:(void (^)(BOOL add_noDel, BOOL IsSuccess))failure{
    NSString *updateType = addOrDel ? @"add" : @"del";
    NSDictionary *dict = @{@"bookId":@(bookId),@"action":updateType};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_favorUpdate andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(addOrDel,YES);
    } failure:^(NSError *error) {
        if (failure)failure(addOrDel,NO);
    }];
}

//阅读器内图书推荐相似图书
-(void)readSimilarBookListForBookid:(NSInteger)bookid Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = YES;
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"bookId":@(bookid)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_similarUpdate baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_similarUpdate,@(userInfo.uid),userInfo.country_code,@(bookid)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//出版社
-(void)getPublisherListFromNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getPublisherData baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getPublisherData,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}
//发现
-(void)getExploreDataFromNetSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getExploreData baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getExploreData,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//搜索(其他小朋友都在读)
-(void)getSearchResults_OtherKidsReadingFormNetWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"word":@"",@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getSearchResults baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getSearchResults,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}
//搜索(按字段匹配)
-(void)getSearchResultsWithKeyWord:(NSString*)keyWord PageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    NSDictionary* dict = @{@"word":keyWord,@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getSearchResults andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//原生系列
-(void)getOriginSeriesWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getBookOfOriginalSeries baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getBookOfOriginalSeries,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}
//notice请求
- (void)getNoticeSuccess:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {

    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getNoticeList andBaseUrl:__Ser3_0_URL_Base_ parameters:@{} success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取弹屏
- (void)getPopupsSuccess:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getPopUp andBaseUrl:__Ser3_0_URL_Base_ parameters:@{} success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//与服务器同步语音List(通过文件目录添加删除)
- (void)operateRecordWithBookId:(NSInteger)bookId SaveList:(NSArray*)saveList DeleteList:(NSArray*)deleteList Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    //参数
    NSString *deleteArrayStr = [deleteList componentsJoinedByString:@","];
    
    NSData* Data = [NSJSONSerialization dataWithJSONObject:saveList options:NSJSONWritingPrettyPrinted error:nil];
    NSString* jsondate = @"";
    if (Data) {
        jsondate = [[NSString alloc] initWithBytes:Data.bytes length:Data.length encoding:NSUTF8StringEncoding];
    }
    NSDictionary* param = @{@"bookId":@(bookId),@"saveList":jsondate,@"deleteList":deleteArrayStr};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_operateRecording andBaseUrl:__Ser3_0_URL_Base_ parameters:param success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//删除整本书录音
-(void)deleteBookAllPageRecordWithBookId:(NSInteger)bookId Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    //参数
    NSDictionary* param = @{@"bookId":@(bookId)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_deleteRecording andBaseUrl:__Ser3_0_URL_Base_ parameters:param success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取排行榜
-(void)getRankListWithRankId:(NSInteger)rankId Range:(NSString*)range Rtype:(NSNumber *)rtype Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    
    NSDictionary* dict = @{@"rankId":@(rankId),@"range":range};
    NSMutableDictionary *pDic = [NSMutableDictionary dictionaryWithDictionary:dict];
    NSString *keyStr = [NSString stringWithFormat:@"%ld_%@",(long)rankId,range];
    if (rtype) {
        [pDic setObject:rtype forKey:@"rtype"];
        keyStr = [NSString stringWithFormat:@"%ld_%@_%@",(long)rankId,range,rtype.description];
    }
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getRankList baseUrl:__Ser3_0_URL_Base_ parameters:pDic keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getRankList,@(userInfo.uid),userInfo.country_code,keyStr] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//分享到发现
-(void)shareToExploreWithBookId:(NSInteger)bookId ActCode:(NSString*)actCode ShareTitle:(NSString*)shareTitle Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    NSDictionary* dict = @{@"bookId":@(bookId), @"actCode":actCode,@"shareTitle":shareTitle};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_shareToExplore andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//分享到第三方
-(void)shareToOthersWithBookId:(NSInteger)bookId Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    NSDictionary* dict = @{@"bookId":@(bookId)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_shareOthers andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}


//获取小书房首页
-(void)getBookHouseDataWithTargetID:(NSInteger)targetID Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    if (!targetID) {
        return;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSString *keyStr = [NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getBookHouseData,@(userInfo.uid),userInfo.country_code];
    if (userInfo.uid != targetID) {
       keyStr = [NSString stringWithFormat:@"%@_%@",__keyId_port_getBookHouseData,@(targetID)];
    }
    
    NSDictionary* dict = @{@"role":@(userInfo.role),@"isLocked":@([CacheData shareSingle].isLockedDeviceLogin),@"targetUserId" : @(targetID)};
    
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getBookHouseData baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:keyStr success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}
//只获取小书房的缓存
-(void)getBookHouseCacheBack:(void (^)(NSDictionary* retDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCahce shareSingle] getCacheWithPort:__port_server_getBookHouseData BaseUrl:__Ser3_0_URL_Base_ KeyId:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getBookHouseData,@(userInfo.uid),userInfo.country_code] CacheBack:^(NSDictionary *retDict) {
        if (cacheBack) cacheBack(retDict[@"retinfo"]);
    }];
}

//初始化筛选项
- (void)getFilterInitDataSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_filterInit baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_filterInit,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

- (void)getFilterOpchgDataWithPara:(NSDictionary *)para Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (!para) {
        return;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_filterOpchg baseUrl:__Ser3_0_URL_Base_ parameters:para keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_filterOpchg,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

- (void)getFilterListWithPara:(NSDictionary *)para success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (!para) {
        return;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_filterList baseUrl:__Ser3_0_URL_Base_ parameters:para keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_filterOpchg,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//单本书架
- (void)getOneBookWithBookId:(NSInteger)bookId success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (!bookId) {
        return;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* dict = @{@"bookId":@(bookId)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getOneBook baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getOneBook,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//清除首页的五分钟限制时间
- (void)cleanHomePageLimitedDate_once{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_cleanLastLimitedDateWithPort:__port_server_getLibrary BaseUrl:__Ser3_0_URL_Base_ keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getLibrary,@(userInfo.uid),userInfo.country_code]];
}

//保存读书后的图像
-(void)storePathForPhotoInUpYunWithActivityId:(NSInteger)activityId PathArray:(NSArray*)pathArray Success:(void (^)(NSDictionary* retDict))success Failure:(void (^)(NSError* error))failure{
    NSData* Data = [NSJSONSerialization dataWithJSONObject:pathArray options:NSJSONWritingPrettyPrinted error:nil];
    NSString* jsondate = @"";
    if (Data) {
        jsondate = [[NSString alloc] initWithBytes:Data.bytes length:Data.length encoding:NSUTF8StringEncoding];
    }
    NSDictionary *dict = @{@"activityId":@(activityId),@"photoList":jsondate};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_savePicture andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

-(void)cancelUploadPhotoPath{
    [[NetRequestWithCahce shareSingle] cancelTaskWithPort:__port_server_savePicture baseUrl:__Ser3_0_URL_Base_];
}

//照片分享到发现
-(void)sharePhotoToExplorWithBookId:(NSInteger)bookId ActivityId:(NSInteger)activityId HurdleNo:(NSInteger)hurdleNo Success:(void (^)(NSDictionary* retDict))success Failure:(void (^)(NSError* error))failure{
    NSDictionary *dict = @{@"bookId":@(bookId),@"activityId":@(activityId),@"hurdleNo":@(hurdleNo)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_sharePhotoToExplore andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取照片边框样式
-(void)getPhotoBorderStyleAndSpritImageWithBookId:(NSInteger)bookId Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack;{
    NSDictionary* params = @{@"bookId":@(bookId)};
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getPhotoBorderStyle baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getPhotoBorderStyle,@(userInfo.uid),userInfo.country_code,@(bookId)] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success) success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure) failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack) cacheBack(cacheRetDict);
    }];
}

//获取阅读统计
-(void)getUserReadingStatFromNetWithtargetId:(NSInteger)targetId Rtime:(NSString*)rtime F:(NSInteger)f Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    if (!targetId) {
        return;
    }
    BOOL isNeedCache = NO;
    if (f == 1) {
        isNeedCache = YES;
    }
    NSString *tsSub = [NSDate timeString_zone_cur_utc];
    NSDictionary* dict = @{};
    if (rtime) {
        dict = @{@"targetUserId":@(targetId), @"f":@(f),@"rtime":rtime,@"tz":tsSub};
    }else{
        dict = @{@"targetUserId":@(targetId),@"f":@(f),@"tz":tsSub};
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSString *keystr = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getUserReadingStat,@(targetId),userInfo.country_code,@(f)];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getUserReadingStat baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:keystr NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}
//上传评测结果或者获取某一页全部句子的评测结果
-(void)updateOrGetOnePageRadioEvalsWithBookId:(NSInteger)bookId PageIndex:(NSInteger)pageIndex EvalJsonStr:(NSString*)evalJsonStr Success:(void (^)(NSDictionary* retDict))success Failure:(void (^)(NSError* error))failure{
    NSMutableDictionary* params = [NSMutableDictionary new];
    if (bookId != 0) {
        [params setValue:@(bookId) forKey:@"bookId"];
    }
    if (pageIndex != 0) {
        [params setValue:@(pageIndex) forKey:@"pageIndex"];
    }
    if (evalJsonStr) {
        [params setValue:evalJsonStr forKey:@"evalJsonStr"];
    }
    //网络请求
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getRadioEvalResult andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
    
}

//捉鬼接口
-(void)cacheGostWithGID:(NSInteger)gid Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    NSDictionary* dict = @{@"gId":@(gid)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_catchGost andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//我页面获取用户信息
- (void)aboutMeGetUinfoWithTargetUid:(NSInteger)targetUid success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (targetUid) {
        NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_aboutMeUinfo,@(targetUid).description];
        NSDictionary *dict = @{@"targetUserId" : @(targetUid)};
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_aboutMeUinfo baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:key NeedCache:YES success:^(NSDictionary *retDict, BOOL hasCache) {
            if (success)success(retDict,hasCache);
        } failure:^(NSError *error, BOOL hasCache) {
            if (failure)failure(error,hasCache);
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
        }];
    }
}
//
//获取推荐更多图书
-(void)getRecommendMoreBooksFromNetWithPageIndex:(NSInteger)pageIndex OrderBy:(NSString*)orderBy Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"pageIndex":@(pageIndex),@"orderBy":orderBy};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getRecommendMore baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@_%@",__keyId_port_getRecommendMore,@(userInfo.uid),userInfo.country_code,@(pageIndex),orderBy] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
    
}
//
//获取达人榜更多
-(void)getTalentRankListWithCodeType:(NSString*)codeType Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    NSDictionary* params = @{@"codeType":codeType};
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getMoreTalentRank baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getMoreTalentRank,@(userInfo.uid),userInfo.country_code,codeType] success:^(NSDictionary *retDict,BOOL hasCache) {
        if (success &&retDict)success(retDict,hasCache);
    } failure:^(NSError *error,BOOL hasCache) {
        if (failure)failure(error,hasCache);
        
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
        
    }];
}
//
//下拉获取动态
-(void)getMoreNewsFromNetWithDirect:(NSInteger)direct IndexId:(NSInteger)indexId Success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    NSDictionary* dict = @{@"direct":@(direct),@"indexId":@(indexId)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getMoreNews andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取我的成长
- (void)getMyGrothWithTargetUid:(NSInteger)targetUid success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (targetUid) {
        NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_myGrowth,@(targetUid).description];
        NSString *tsSub = [NSDate timeString_zone_cur_utc];
        NSDictionary *dict = @{@"targetUserId" : @(targetUid),
                               @"timeZone" : tsSub};
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_myGrowth baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:key NeedCache:YES success:^(NSDictionary *retDict, BOOL hasCache) {
            if (success)success(retDict,hasCache);
        } failure:^(NSError *error, BOOL hasCache) {
            if (failure)failure(error,hasCache);
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
        }];
    }
}

//获取用户粉丝列表
- (void)getUserFansListWithTargetUid:(NSInteger)targetUid page:(NSInteger)page success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (targetUid) {
        NSString *key = [NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getUserFans,@(targetUid).description,@(page).description];
        NSDictionary *dict = @{@"targetId" : @(targetUid),@"page":@(page)};
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getUserFans baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
            if (success)success(retDict,hasCache);
        } failure:^(NSError *error, BOOL hasCache) {
            if (failure)failure(error,hasCache);
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
        }];
    }
}

//获取用户关注列表
- (void)getUserFollowsListWithTargetUid:(NSInteger)targetUid page:(NSInteger)page success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (targetUid) {
        NSString *key = [NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getUserFollows,@(targetUid).description,@(page).description];
        NSDictionary *dict = @{@"targetId" : @(targetUid),@"page":@(page)};
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getUserFollows baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
            if (success)success(retDict,hasCache);
        } failure:^(NSError *error, BOOL hasCache) {
            if (failure)failure(error,hasCache);
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
        }];
    }
}

//关注或者取消关注
- (void)userFollowsAcitonWithTargetUid:(NSInteger)targetUid actionType:(NSInteger)aciotnType success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    NSDictionary* dict = @{@"followUserId":@(targetUid),
                           @"follow" : @(aciotnType)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_follwsAction andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//
//获取故事卡列表
-(void)getStoryCardsListSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getStoryCardList baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:[NSString stringWithFormat:@"%@_%@_%@",__keyId_port_getStoryCardList,@(userInfo.uid),userInfo.country_code] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success) success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure) failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack) cacheBack(cacheRetDict);
    }];
}
//获取故事卡详情
-(void)getStoryCardsInfoWithCardCode:(NSString*)cardCode Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    NSDictionary* params = @{@"cardCode":cardCode};
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getStoryCardInfo baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getStoryCardInfo,@(userInfo.uid),userInfo.country_code,cardCode] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success) success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure) failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack) cacheBack(cacheRetDict);
    }];
}

//邀请好友列表
- (void)getinviteHistorySuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSString* udid = [self getUMSuiid];
    NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_getInviteHistroy,@(userInfo.uid).description];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_inviteHistory baseUrl:__Ser3_0_URL_Base_ parameters:@{@"device":udid} keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success) success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure) failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack) cacheBack(cacheRetDict);
    }];
}

//邀请好友
- (void)inviteHistoyWithInviteCode:(NSString *)inviteCode success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    NSString* udid = [self getUMSuiid];
    NSDictionary* dict = @{@"inviteCode":inviteCode,
                           @"device":udid};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_inviteFirend andBaseUrl:__Ser3_0_URL_Base_ parameters:dict success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//
//获取功能页数据
- (void)getFuncPageBuddyListWithBookId:(NSInteger)bookId Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack{
    NSDictionary* params = @{@"bookId":@(bookId)};
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getBookReadFuncInfo baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getBookReadFuncInfo,@(userInfo.uid),userInfo.country_code,@(bookId)] success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success) success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure) failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack) cacheBack(cacheRetDict);
    }];
}
//
//获取当前WaWa币
- (void)getMyWawaCoinSuccess:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getMyWawaCoin andBaseUrl:__Ser3_0_URL_Base_ parameters:@{} success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//获取当前可以获得的故事卡
- (void)getAvailableStoryCardWithBookId:(NSInteger)bookId Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSDictionary* params = @{@"bookId":@(bookId)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_availableStoryCard andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//获取书内故事卡成功通知服务器
- (void)getStoryCardInBookSuccessWithCardCode:(NSString*)cardCode CardPieceNum:(NSInteger)cardPieceNum Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSDictionary* params = @{@"cardCode":cardCode,@"cardPieceNums":@(cardPieceNum)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getBookStoryCardSuccess andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//获取用户创作
- (void)getUserDesignWithTargetUid:(NSInteger)targetUid success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (targetUid) {
        NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_getUserDesign,@(targetUid).description];
        NSDictionary *dict = @{@"targetUserId" : @(targetUid),};
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getUserDesign baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:key NeedCache:YES success:^(NSDictionary *retDict, BOOL hasCache) {
            if (success)success(retDict,hasCache);
        } failure:^(NSError *error, BOOL hasCache) {
            if (failure)failure(error,hasCache);
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
        }];
    }
    
}
//获取用户更多创作
- (void)getUserMoreDesignWithTargetID:(NSInteger)targetId moreCode:(NSString *)moreCode pagenIndex:(NSInteger)pageIndex success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (targetId && moreCode) {
        NSString *key = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getMoreDesign,@(targetId).description,moreCode,@(pageIndex).description];
        NSDictionary *dict = @{@"targetUserId" : @(targetId),@"code" : moreCode,@"pageIndex":@(pageIndex)};
        BOOL needCache = NO;
        if (pageIndex == 1) {
            needCache = YES;
        }
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getMoreDesign baseUrl:__Ser3_0_URL_Base_ parameters:dict keyID:key NeedCache:needCache success:^(NSDictionary *retDict, BOOL hasCache) {
            if (success)success(retDict,hasCache);
        } failure:^(NSError *error, BOOL hasCache) {
            if (failure)failure(error,hasCache);
        } cache:^(NSDictionary *cacheRetDict) {
            if (cacheBack)cacheBack(cacheRetDict);
        }];
    }
}

//获取vip兑换配置信息
- (void)getVipSetupInfoSuccess:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_getVipSetup,@([CacheData shareSingle].getUserLoginInfo.uid).description];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getVipSetup baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
    
}

//兑换Vip
- (void)exchangeVipWithExchangeID:(NSInteger)exchangeID uccess:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    if (exchangeID) {
        NSDictionary *dic = @{@"exchangeId":@(exchangeID)};
        [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_exchangeVip andBaseUrl:__Ser3_0_URL_Base_ parameters:dic success:^(NSDictionary *retDict) {
            if (success)success(retDict);
        } failure:^(NSError *error) {
            if (failure)failure(error);
        }];
    }
    
}
//获得wawa币yaya豆奖励接口
- (void)rewardActionWithActCode:(NSString*)actCode Param:(NSString*)param Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSDictionary* params = @{@"actCode":actCode};
    if (param) {
        params = @{@"actCode":actCode,@"param":param};
    }
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_rewardWYAction andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//
//获取用户等级信息
- (void)getUserRankInfoSuccess:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getUserRankInfo andBaseUrl:__Ser3_0_URL_Base_ parameters:@{} success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//分享或打分Vip权限奖励
- (void)shareOrGradeVipReWardWithType:(NSInteger)type Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure {
    //NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
    //NSString * appVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    NSDictionary *dic = @{@"type" : @(type)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_shareReward andBaseUrl:__Ser3_0_URL_Base_ parameters:dic success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}


//获取他人图书
- (void)getOtherBookWithTargetUid:(NSInteger)targetUid orderby:(NSString *)orderby pageIndex:(NSInteger)pageIndex success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (!targetUid || !pageIndex) {
        return;
    }
    if (!orderby || !orderby.length) {
        orderby = @"default";
    }
    NSDictionary* params = @{@"targetUserId":@(targetUid),@"pageIndex":@(pageIndex),@"orderBy":orderby};
    NSString *key = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getOtherBook,@(targetUid).description,orderby,@(pageIndex).description];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getOthersBook baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取他人收藏
- (void)getOtherFavorWithTargetUid:(NSInteger)targetUid orderby:(NSString *)orderby pageIndex:(NSInteger)pageIndex success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    if (!targetUid || !pageIndex) {
        return;
    }
    if (!orderby || !orderby.length) {
        orderby = @"default";
    }
    NSDictionary* params = @{@"targetUserId":@(targetUid),@"pageIndex":@(pageIndex),@"orderBy":orderby};
    NSString *key = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getOtherFavor,@(targetUid).description,orderby,@(pageIndex).description];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getOthersFavor baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

/**搜索关注/他人 relationType:follow(关注),fan（粉丝） */
- (void)searchFollowRalationWithRalationType:(NSString *)relationType targetUid:(NSInteger)targetUid searchStr:(NSString *)searchStr success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    if (!targetUid || !searchStr.length) {
        return;
    }
    NSString *port = __port_server_searchFllowed;
    if ([relationType isEqualToString:@"fan"]) {
        port = __port_server_serarchFan;
    }
    NSDictionary *params = @{@"targetId" : @(targetUid), @"search":searchStr};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:port andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success) success(retDict);
    } failure:^(NSError *error) {
        if (failure) failure(error);
    }];
}

/** 获取自定义结构图书信息 */
- (void)getBookDefineWithExciteDic:(NSDictionary *)exciteDic pageIndex:(NSInteger)pageIndex OrderBy:(NSString*)orderBy Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSMutableDictionary *muPara = [NSMutableDictionary dictionaryWithDictionary:exciteDic];
    [muPara setValue:@(pageIndex) forKey:@"pageIndex"];
    [muPara setValue:orderBy forKey:@"orderBy"];
    NSString *itemType = [exciteDic valueForKey:@"itemType"];
    NSString *itemVal = [exciteDic valueForKey:@"itemVal"];
    
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_bookDefine baseUrl:__Ser3_0_URL_Base_ parameters:muPara keyID:[NSString stringWithFormat:@"%@_%@_%@_%@_%@_%@_%@",__keyId_port_getBookDefine,@(userInfo.uid),userInfo.country_code,@(pageIndex),orderBy,itemType,itemVal] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//签到
//获取今日可能获取的大奖
- (void)getProbablyRewardsSuccess:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_getProbablyRewards andBaseUrl:__Ser3_0_URL_Base_ parameters:@{} success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//点击签到获取今天的奖励
- (void)getTodayRewardSuccess:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_getTodayReward,@([CacheData shareSingle].getUserLoginInfo.uid).description];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getTodayReward baseUrl:__Ser3_0_URL_Base_ parameters:@{} keyID:key success:^(NSDictionary *retDict, BOOL hasCache) {
         if (success)success(retDict);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error);
    } cache:^(NSDictionary *cacheRetDict) {
        
    }];
}

-(void)getTodayRewardCacheBack:(void (^)(NSDictionary* retDict))cacheBack {
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSString *key = [NSString stringWithFormat:@"%@_%@",__keyId_port_getTodayReward,@(userInfo.uid).description];
    [[NetRequestWithCahce shareSingle] getCacheWithPort:__port_server_getTodayReward BaseUrl:__Ser3_0_URL_Base_ KeyId:key CacheBack:^(NSDictionary *retDict) {
        if (cacheBack) cacheBack(retDict[@"retinfo"]);
    }];
}

//小知识点赞
- (void)knowledgeLikeWithKnid:(NSInteger)knid IsLike:(NSInteger)like Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSDictionary *params = @{@"knid" : @(knid),@"like":@(like)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_knowledgeLike andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}
//累计签到奖励
- (void)getCumulativeSignRewardWithDays:(NSInteger)days Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSDictionary *params = @{@"days" : @(days)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_cumulativeSignReward andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//扫一扫
- (void)scanCodeWithCodeStr:(NSString *)codeStr success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    if (!codeStr.length) {
        return;
    }
    NSDictionary *para = @{@"code" : codeStr};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_scanCode andBaseUrl:__Ser3_0_URL_Base_ parameters:para success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//激活码使用
- (void)activityUseWithCodeStr:(NSString *)codeStr success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure {
    if (!codeStr.length) {
        return;
    }
    NSDictionary *para = @{@"code" : codeStr};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_activityCodeUse andBaseUrl:__Ser3_0_URL_Base_ parameters:para success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取阅读器内活动数据
-(void)getReaderInsideActivityInfoWithBookId:(NSInteger)bookId success:(void (^)(NSDictionary * retDict))success failure:(void (^)(NSError *error))failure{
    NSDictionary *para = @{@"bookId" : @(bookId)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__prot_server_getReaderInsideOperInfo andBaseUrl:__Ser3_0_URL_Base_ parameters:para success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//获取订单列表
-(void)getOrderListWithPage:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack;{
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSDictionary* params = @{@"page":@(pageIndex)};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getUserOrderList baseUrl:__Ser3_0_URL_Base_ parameters:params keyID:[NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getUserOrderList,@(userInfo.uid),userInfo.country_code,@(pageIndex)] NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//获取作品列表
- (void)getBookAritcleListWithPageIndex:(NSInteger)pageIndex Success:(void (^)(NSDictionary * retDict,BOOL hasCache))success failure:(void (^)(NSError *error,BOOL hasCache))failure cache:(void (^)(NSDictionary * cacheRetDict))cacheBack {
    BOOL isNeedCache = NO;
    if (pageIndex == 1) {
        isNeedCache = YES;
    }
    NSDictionary *para = @{@"pageIndex":@(pageIndex)};
    UserInfo *userInfo = [CacheData shareSingle].getUserLoginInfo;
    NSString *keyStr = [NSString stringWithFormat:@"%@_%@_%@_%@",__keyId_port_getBookArticleList,@(userInfo.uid),userInfo.country_code,@(pageIndex)];
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithCacheType:RequestType_Post Port:__port_server_getBookArticleList baseUrl:__Ser3_0_URL_Base_ parameters:para keyID:keyStr NeedCache:isNeedCache success:^(NSDictionary *retDict, BOOL hasCache) {
        if (success)success(retDict,hasCache);
    } failure:^(NSError *error, BOOL hasCache) {
        if (failure)failure(error,hasCache);
    } cache:^(NSDictionary *cacheRetDict) {
        if (cacheBack)cacheBack(cacheRetDict);
    }];
}

//第三方支付微信
-(void)weChatPayOrderWithParams:(NSDictionary*)payParams Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_WeChatPayOrder andBaseUrl:__Ser3_0_URL_Base_ parameters:payParams success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

//退款接口
-(void)refundWithOrderId:(NSString*)orderId Success:(void (^)(NSDictionary * retDict))success Failure:(void (^)(NSError *error))failure{
    NSDictionary* params = @{@"orderNo":orderId};
    [[NetRequestWithCache_JR shareSingle] JR_netRequestWithType:RequestType_Post Port:__port_server_refundPayment andBaseUrl:__Ser3_0_URL_Base_ parameters:params success:^(NSDictionary *retDict) {
        if (success)success(retDict);
    } failure:^(NSError *error) {
        if (failure)failure(error);
    }];
}

// getUMSuiid
- (NSString*)getUMSuiid
{
//    NSString* udid = [WY3SDKLogin get_idfv];
//    if ([udid hasPrefix:@"idfv_"]) {
//        return udid;
//    }else {
        return [NSString stringWithFormat:@"idfv_"];
//    }
}

@end
